package com.uphone.kingmall.adapter;

import android.content.Context;
import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.china.zhuoyue.R;
import com.uphone.kingmall.bean.ShopGoodsBean;
import com.uphone.kingmall.utils.GlideUtils;

import java.util.List;

/**
 * <pre>
 *     author : 孙增艳
 *     e-mail : sunzengyan@outlook.com
 *     time   : 2019/3/1
 *     desc   :
 *     version: 1.0
 * </pre>
 */
public class RvShopGoodsAdapter extends BaseQuickAdapter<ShopGoodsBean, BaseViewHolder> {

    private final Context context;

    public RvShopGoodsAdapter(Context context, @Nullable List<ShopGoodsBean> data) {
        super(R.layout.kingmall_item_rv_shop_goods, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, ShopGoodsBean item) {
        ImageView imageView = helper.getView(R.id.iv_goods_image);
        GlideUtils.getInstance().loadNormalImage(context, item.getImageUrl(), imageView);
        helper.setText(R.id.tv_goods_name, item.getName())
                .setText(R.id.tv_goods_price, "¥" + item.getPrice())
                .setText(R.id.tv_goods_xiaoliang, "月销" + item.getXiaoliang());
    }
}
